/*
============================================================================
 Name        : Tabbar.h
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : CTabbar declaration
============================================================================
*/

#ifndef TABBAR_H
#define TABBAR_H

// INCLUDES
#include "Control.h"

// CLASS DECLARATION
class TTabLabel
{
public:
	TTabLabel(const TDesC& aText, TInt aId) 
	{
		iText.Copy(aText);
		iId = aId;
	}

public:
	TBuf<8> iText;
	TInt iId;
};

class MTabbarObserver
{
public:
	virtual void HandleTabbarCommand(TInt aCommand) = 0;
};

class CTabbar : public CControl
{
public:
	~CTabbar();

	static CTabbar* NewL();

	static CTabbar* NewLC();

private:
	CTabbar();

	void ConstructL();

public:
	virtual void Draw(CFbsBitGc& g);

	virtual TBool OnKeyDown(const TInt& keycode);

	void SetRect(const TInt& left,const TInt& top,const TInt& right, const TInt& bottom);

	virtual TBool OnMouseDown(const TPoint& aPt);

	virtual TBool OnMouseMove(const TPoint& aPt);

	virtual TBool OnMouseUp(const TPoint& aPt);

	void SetObserver(MTabbarObserver* aObserver) {iObserver = aObserver;}

	void FocusChanged(TBool aFocus, const TInt keyCode = 0);

	void ResetTabArray();

	void AppendTab(const TDesC& aText, TInt aId);

	TInt TabCount() const {return iTabArray.Count();}

	void SetSelectedId(TInt aId);

	TInt GetSelectedId();

private:
	TInt ButtonConatinsPt(TPoint aPt);

private:
	TInt iFocusIndex;
	TInt iSelectedIndex;
	MTabbarObserver* iObserver;
	RArray<TTabLabel> iTabArray;
	CFont* iFont;
};	

#endif // TABBAR_H
